package com.ds.smartstudio.service.impl;

import com.ds.smartstudio.service.SendMessageService;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
public class SendMessageImpl implements SendMessageService  {


    @Override
    public void messageSend(String tel) throws IOException {
        Integer[] codeList=new Integer[]{48,65,97};
        String code="";
        for(int i=1;i<=4;i++){
            int codeListsub=(int)(Math.random()*3);
            switch (codeList[codeListsub]){
                case 48:
                    code+=(char)(48+Math.random()*10);
                    break;
                case 65:
                    code+=(char)(65+Math.random()*25);
                    ;break;
                case 97:
                    code+=(char)(97+Math.random()*25);
                    ;break;
            }
        }

        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpGet httpGet = new HttpGet("http://localhost:6060/mod?receiver="+tel+"&pram1=13点10分&pram2=xxxx&pram3="+code+"&mod=3");
        CloseableHttpResponse reponse = httpclient.execute(httpGet);

    }
}
